Skip to main content

All Questions

Tagged with
-1votes
2answers
67views

set output into variable from grep from input variable

whats wrong with this bash script: acme2=$(dig txt @$1 _acme-challenge.$1.de) acme3=$(echo $acme2 | grep "^_acme") ...
dg1kpc's user avatar
5votes
4answers
520views

Getting multiple variables from the output of docker exec command in a bash script?

I would like to execute a script on a host machine (script_on_host.sh), which then reaches inside a docker container in order to grab some data using a second script (script_in_container.sh). The data ...
teeeeee's user avatar
1vote
2answers
212views

Redirect to a filename that will be a variable and contain a command substitution

I'm using nmap to scan a network and then create an XML file that contains the scanned information. I want that XML file to contain the date of the scan so that each file is unique and I can see the ...
johnmacward's user avatar
1vote
1answer
334views

Change hostname with a variable with for loop

I am trying to change the "hostname --transient" to some computers with a for loop using a variable. I want it to collect the "hostname -f" from the server itself and, using the ...
henrolos's user avatar
0votes
1answer
706views

Shell scripting, reading a list from tt file, use as variable, use the variable to run python scripts in a foor loop

I am trying to run a shell script where it reads the variables from a txt file, uses that variable in a for loop to run python file. The code reads a txt file where at least there are 100 variable ...
BircanA's user avatar
0votes
2answers
247views

How to get the Path difference and store it in a variable

Suppose I have two paths. Path1 which is static and path2 which is dynamic. Example: Path1= /tmp/folder/ Path2= /tmp/folder/dir1/dir1_2 Result: Diff= /dir/dir1_2 I want to achieve as above example....
Asif Ahmed's user avatar
-3votes
1answer
60views

Command prompt write a command

its asks me to Store the output of the command “hostname” in a variable. Display “This script is running on _.” where “_” is the output of the “hostname” command. how can I do that
Fn9092's user avatar
7votes
3answers
867views

Remove repeating string pattern from variable with POSIX parameter expansion

I wanted to use 2.6.2 Parameter Expansion to remove leading characters from a string, but was surprised to find out that "Remove Largest Prefix Pattern" doesn't automatically repeat the ...
finefoot's user avatar
9votes
2answers
793views

In POSIX scripting, is x=$y always equivalent to x="$y"?

Are x=$y and x="$y" always equivalent? Didn't know how to search for this. So far, I've always been using x="$y" to be "on the safe side". But I used x=$1 at one point ...
finefoot's user avatar
0votes
1answer
672views

Assigning $* in shell script from args array

After iterating thru the shell arguments and filtering out unwanted arguments into an array, I want to assign the array back to $*. For example, in the below script, I want to remove the arguments -f ...
user3118280's user avatar
1vote
0answers
259views

How to run input (x|grep y) in command [duplicate]

lets say when I execute command and then grep it for a specific output. for example: man cat|grep "Written" This gives the name of the authors. My problem is I want to do this via read. here ...
user525799's user avatar
0votes
1answer
1kviews

How to verify if variable is present when using set -Euo pipefail? [duplicate]

I use following code to verify if variable is not empty and this works fine VAR=(var1 var2 var3) chec_var() { for item in "${@}"; do if [ -z "${!item}" ]; then returncode=1 ...
Rafal Niznik's user avatar
2votes
2answers
2kviews

sed with external script file - How to apply shell variables?

Directly on the command line, this works: $sed "s/a/X/;s/X/&a&/" file and so does using shell variables: $varin=a ; varout=X ; sed "s/$varin/$varout/;s/$varout/&$varin&/...
FelixJN's user avatar
  • 13.9k
1vote
2answers
3kviews

Using test and date to compare current hour ro range

I am new to Gnu/Linux and bash, and I am trying, unsuccessfully, to write a simple bash script to test if date +%H is within a predefined range of hours. Example: hour='date +%H' if [[ $hour -ge 12 ]] ...
tigger's user avatar
1vote
4answers
123views

String substitution to detect empty variables?

I have a script that iterates through files and does some string substitution to insert the date. #!/bin/bash f="/tmp/file.txt" # with .txt extension timestamp="$(date +%H%M%S)" ...
user427603's user avatar

153050per page
close